<?php

namespace App\Http\Models;

use Illuminate\Database\Eloquent\Model;

class Member extends Model
{
    public $table = 'members';
    public $primaryKey = 'id';
    public $fillable = ['username', 'password', 'email', 'phoneNumber', 'type', 'avatar', 'gender', 'money', 'education', 'job'];
    public $timestamps = true;

    // 静态属性
    public static  $typeData = [
        0 => '保密',
        1 => '普通会员',
        2 => '讲师',
        3 => '总监',
        4 => '院长',
        5 => '研究员',
    ];

    public static  $educationData = [
        0 => '保密',
        1 => '大专',
        2 => '专科',
        3 => '本科',
        4 => '硕士',
        5 => '博士',
    ];

    // 定义一个会员类型的转换的方法
    public function convertType($typeId)
    {
        // 返回对应的typeid对应的中文 1. 普通会员 2. 讲师 3. 总监
        $data = [
            0 => '保密',
            1 => '普通会员',
            2 => '讲师',
            3 => '总监',
        ];
        return isset($data[$typeId]) ? $data[$typeId] : '暂无信息';

    }
    // 定义一个学历转换的方法
    public function convertEducation($educationId)
    {
        // 返回对应的typeid对应的中文 1. 普通会员 2. 讲师 3. 总监
        $data = [
            0 => '保密',
            1 => '大专',
            2 => '专科',
            3 => '本科',
            4 => '硕士',
            5 => '博士',
        ];
        return isset($data[$educationId]) ? $data[$educationId] : '暂无信息';

    }

}
